﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TMSimulator
{
    class ExposureTimeFactor: IFactor
    {
        public ExposureTimeFactor() { }

        public double getFactoredTMScore(double originalTMscore, object data)
        {
            if (data.GetType() == typeof(TimeSpan))
            {
                double ans = originalTMscore;
                TimeSpan ts = (TimeSpan)data;
                int seconds = ts.Seconds;

                if (0 <= seconds && seconds <= 3)
                {
                    ans *= 0.1;
                }
                else if (3 <= seconds && seconds <= 10)
                {
                    ans *= 0.5;
                }
                
                return ans;
            }
            else
            {
                Console.Error.WriteLine("data type provided is not of TimeSpan, returned original TMScore.");
                return originalTMscore;
            }
        }

        public string getDescription()
        {
            string ans =
                "This factor receives a TimeSpan object in addition to the original TMScore. " +
                Environment.NewLine +
                "The return function is based on the following set of rules:" +
                Environment.NewLine +
                "\t1.\t 0-3\t seconds exposure - 10% of original TMScore" +
                Environment.NewLine +
                "\t2.\t 3-10\t seconds exposure - 50% of original TMScore" +
                Environment.NewLine +
                "\t3.\t 10+\t seconds exposure - 100% of original TMScore";
                
            return ans;
        }
    }
}
